﻿using System;
using System.ComponentModel;
using System.Web.UI;

namespace Portal.Api.Controls
{
  /// <summary>
  /// Summary description for LanguageLinkButton.
  /// </summary>
  [DefaultProperty("LanguageRef")]
  [ToolboxData(@"<{0}:RangeValidator runat=""server""></{0}:RangeValidator>")]
  public class RangeValidator : System.Web.UI.WebControls.RangeValidator
  {
    private string languageRef = "";
    private string languageRefText = "";

    [DefaultValue("")]
    public string LanguageRef
    {
      get { return languageRef; }
      set { languageRef = value; }
    }

    [DefaultValue("")]
    public string LanguageRefText
    {
      get { return languageRefText; }
      set { languageRefText = value; }
    }

    protected override void OnPreRender(EventArgs e)
    {
      if (!string.IsNullOrEmpty(LanguageRefText))
      {
        base.Text = Portal.Api.Language.GetText(Portal.Api.Module.GetModuleControl(this), LanguageRefText);
      }
      if (!string.IsNullOrEmpty(LanguageRef))
      {
        base.ErrorMessage = Portal.Api.Language.GetText(Portal.Api.Module.GetModuleControl(this), LanguageRef);
      }
      base.OnPreRender(e);
    }

  }
}
